﻿@model WmWebSystem.Models.ChildProject
@{
    ViewBag.Title = "添加项目文件";
    Layout = "~/Views/Shared/_Layout_manage.cshtml";
}
<link href="@Url.Content("~/Scripts/JqueryUI/css/start/jquery-ui-1.8.13.custom.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/JqueryUI/jquery-ui-1.8.13.custom.min.js")" type="text/javascript"></script>

<div class="contentcontainer">
    <div class="headings">
        <h2>添加项目文件</h2>
    </div>
    <div class="contentbox">
          @*@using (Html.BeginForm("Create", "Item", FormMethod.Post, new { enctype = "multipart/form-data" }))
          {
            @Html.ValidationSummary(true)*@
            <table>
                <tr>
                    <th width="200px">项目编号</th>
                    <td>
                      <input type="text" id="projectNo" disabled="disabled"  value="@ViewBag.No" />
                    </td>
                </tr>
                <tr>
                    <th>添加附件</th>
                    <td>
                        @*<input type="file" id="fileItem" name="Item1" />
                        <input type="submit" value="确认添加>>" class="btn" />*@
                        <div>
                            <input type="text" id="fileName" />
                            <span id="spanButtonPlaceHolder">浏览</span>
                            <button id="btnSubmit">上传</button>
                        </div>
                        <div title="文件上传进度" id="fileProgress" style="display: none">
                            <div id="progressbar"></div>
                            <button id="cancelButton">取消上传</button>
                            当前上传速度： <span id="CurrentSpeed"></span>
                        </div>
                    </td>
                </tr>
            </table>
          @*}*@
        <div style="clear: both;"></div>
    </div>
</div>



@section Head{
    <script src="@Url.Content("~/Scripts/SwfUpload/swfupload.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/SwfUpload/plugins/swfupload.queue.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/SwfUpload/plugins/swfupload.speed.js")" type="text/javascript"></script>

    <script type="text/javascript">
        var swfu;
        window.onload = function () {
            var _pno = document.getElementById("projectNo");
            var _no = _pno.value;
            swfu = new SWFUpload({
                upload_url: "/Item/Swfupload?pno=" + _no,
                flash_url: "/Scripts/SwfUpload/Flash/swfupload.swf",
                file_size_limit: "11500 MB",
                file_types: "*.*",
                file_types_description: "All Files",
                file_upload_limit: 0,
                file_queue_limit: 1,
                debug: false,

                // Button settings
                button_image_url: "/Scripts/SwfUpload/Images/TestImageNoText_65x29.png",
                button_width: "65",
                button_height: "29",
                button_placeholder_id: "spanButtonPlaceHolder",
                button_text: '<span class="theFont">浏览</span>',
                button_text_style: ".theFont { font-size: 14; }",
                button_text_left_padding: 12,
                button_text_top_padding: 3,


                file_dialog_complete_handler: function (numFilesSelected, numFilesQueued) {
                },
                file_queued_handler: function (file) {
                    $("#fileName").val(file.name);
                },
                upload_progress_handler: function (file, complete, total) {
                    var value = complete / total * 100;
                    $("#progressbar").progressbar("value", value);
                    $("#CurrentSpeed").html(SWFUpload.speed.formatBPS(file.currentSpeed));
                },
                upload_success_handler: function (file, data) {
                    alert("文件上传成功");
                    $("#fileProgress").dialog("close");
                }

            });
            $("#btnSubmit").click(function () {
                if (swfu.getStats().files_queued > 0) {
                    $("#fileProgress").dialog({
                        modal: true,
                        width: 400,
                        open: function () {
                            $("#progressbar").progressbar({
                                value: 0
                            });

                            swfu.startUpload();

                        }
                    });
                }

            });

            $("#cancelButton").click(function () {
                swfu.stopUpload();
            });
        };
    </script>
}





